package com.sendi.system.action;

import java.io.IOException;
import java.util.List;

import net.sf.json.JSONObject;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.beans.BeanUtils;

import com.sendi.system.entity.SysProloadConf;
import com.sendi.system.entity.SysSocketInterface;

/*
 * 定时任务日志
 */
public class SysJobLogAction extends SysAction {
	
	private Integer id;
	
 
	private String jobdesc;
	private String jobstartTime;
	private String jobendTime;
	private String jobName;
	private String jobGroupname;
	
	
	public SysJobLogAction()
	{
		super();
		data_session_name="SysJobLogActionData";
	}
	
	
	public void sysJobLogInit()
	{
		List datas=null;
		
		if(getSession().getAttribute(data_session_name)!=null)
		{
			datas=(List)getSession().getAttribute(data_session_name);
	 	}
		else
		{
			addDataToSession();
			datas=(List)getSession().getAttribute(data_session_name);
		}
		 
			writeJSONArray(datas);
		 
	}
	
	@Override
	public void addDataToSession()
	{
		List datas=null;
		String hql="from  SysJobInterfaceLog ";
	 	datas=serviceSupportImp.findByHQL(hql);
	 	getSession().setAttribute(data_session_name,datas);
	}
	
	public void querysysJobLogData()
	{
		   try
		   {
			     Session session=serviceSupportImp.getDao().getSessionFactory().openSession();
			 	StringBuffer hql=new StringBuffer("from SysJobInterfaceLog where 1=1 ");
				if(this.jobName!=null&&jobName.trim().length()>0)
				{
					hql.append(" and  jobName like :jobName ");
				}
				if(this.jobdesc!=null&&jobdesc.trim().length()>0)
				{
					hql.append(" and  jobdesc like :jobdesc ");
				}
			 	
				   Query query= session.createQuery(hql.toString());
				   if(jobName!=null&&jobName.trim().length()>0)
					{
					  query.setParameter("jobName", "%"+jobName+"%");
					}
				   if(jobdesc!=null&&jobdesc.trim().length()>0)
					{
					  query.setParameter("jobdesc", "%"+jobdesc+"%");
					}
				 	    List datas=query.list();
				      	getSession().setAttribute(data_session_name,datas);	
				     	writeResponseText("{success:true,msg:'success',datasize:"+datas.size()+"}");
		   			}
		   catch (Exception e) {
			   writeResponseText("{success:false,msg:'failure'}");
				 
		}
		    
		
	}
 
 
 
		
		public void excuteDeletesysJobLog()
		{
		  String hql="delete SysJobInterfaceLog where id in ("+deleterecord+")";
		  Session session=serviceSupportImp.getDao().getSessionFactory().openSession();
		  session.beginTransaction();
		  session.createQuery(hql).executeUpdate();
		  session.getTransaction().commit();
		  addDataToSession();
		  writeResponseText("{success:true,msg:'success'}"); 
		}
		
		
	public Integer getId() {
		return id;
	}


	public void setId(Integer id) {
		this.id = id;
	}


	public String getJobdesc() {
		return jobdesc;
	}


	public void setJobdesc(String jobdesc) {
		this.jobdesc = jobdesc;
	}


	public String getJobstartTime() {
		return jobstartTime;
	}


	public void setJobstartTime(String jobstartTime) {
		this.jobstartTime = jobstartTime;
	}


	public String getJboendTime() {
		return jobendTime;
	}


	public void setJboendTime(String jobendTime) {
		this.jobendTime = jobendTime;
	}


	public String getJobName() {
		return jobName;
	}


	public void setJobName(String jobName) {
		this.jobName = jobName;
	}


	public String getJobGroupname() {
		return jobGroupname;
	}


	public void setJobGroupname(String jobGroupname) {
		this.jobGroupname = jobGroupname;
	}

 
 

 
	

}
